Skip to content

fix(cli): a host can name projects whose received files are expected or all received - #8025

Merged
xuanruli merged 4 commits into
mainfrom
fix/missing-provenance-record
Nov 17, 2026
Merged

xuanruli merged 4 commits into
mainfrom
fix/missing-provenance-record

Conversation

@xuanruli

@xuanruli xuanruli commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

A host app that imports projects can now tell the CLI how to read each project's received-files record. It does this through a state file named by HYPERFRAMES_RECEIVED_STATE_FILE, and each project is listed with one of two states:

  • "expected": the project must carry .hyperframes/received-files.json. If the file is missing, every file counts as received, and the CLI does not start a new record in its place.
  • "all": every file in the project counts as received, whatever the record lists.

Separately, a record lock whose mtime is in the future is now treated as stale, the same as a lock older than ten seconds.

Why

Today the CLI reads a missing received-files record as "nothing received" and an unreadable one as "everything received". That default suits projects people make themselves. An app that imports projects and keeps their records knows more than that:

  • It knows when a record should exist, so a missing one is unknown, not "nothing".
  • It can know that a project is in the middle of work whose provenance is not recorded yet. For that window, the safe reading is "all received".

The host keeps this in a file rather than an environment value. That way long-lived child processes see updates, and a long list of projects never goes onto a command line.

A lock dated in the future never became stale, so every writer waited and then failed.

Related work

None.

How

  • hostStates() opens the named JSON file once, reads its identity and content through that handle, and caches by identity, size and timestamps. The handle is closed even when parsing fails.
    • Each entry has an absolute path and a received state, plus optional dev/ino that match the folder after a rename or move on the same disk.
    • If the variable is set but the file is missing or malformed, every project counts as "all".
  • readRecord treats an absent record in any named folder as unreadable. Every existing reader inherits this: receivedFiles, receivedRecordStatus, the walks above and below, and record writes, so add does not start a fresh record.
  • receivedRecords adds an unreadable record when an "all" project is the folder being read, one of its subfolders, or a folder that holds it.
  • tryRecordLock takes over a lock dated more than one second in the future.
  • Documented in docs/packages/cli.mdx, next to the section on left-out references.

Test plan

  • Unit tests added in privateProjectFile.test.ts ("a host's received state file", plus "takes over a lock dated in the future"). They cover:
    • an expected record that is missing, read from the project, a subfolder and the parent folder
    • an expected record that is present and read as written
    • a project marked all, with an empty record
    • a renamed folder matched by identity
    • a state file that is malformed or missing
    • no fresh record started for an expected project
    • an unnamed project, unaffected
    • Six of these tests fail without the change.
  • Independent Devbox run at the final tree: privateProjectFile / receivedRender / add, 150 passed and 1 platform skip (151 total), one worker. Normal pre-commit and commit-msg checks passed remotely against the identical staged tree; the commit is SSH signed.
  • Source-pair integration: Desktop runLaunch to actual CLI cloud-render dry-run excludes outside assets during active received-source work and after record deletion, even with explicit outside-file approval. Published-artifact verification remains outstanding.
  • Documentation updated
  • Comments follow CONTRIBUTING.md "Comments"

@mintlify

mintlify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
hyperframes 🟢 Ready View Preview Nov 17, 2026, 6:14 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 267 (base branch 267), smooth 94 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (8)

Unstable (1)

  • seqplainkeys-none-pct-r0-nested-z100: tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo false, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true / tracking 0.05, pressJump 0, drop 0, reload 0, render 0.02, renderKey -, undo true, teleport true

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE at 89cdc275

  • A host-named project with a missing record now reads as unknown (privateProjectFile.ts:91). Every reader goes through readRecord: render, benchmark, preview/studio render, publish, cloud render (via publish staging) and add. No caller is left on the old record-only check.
  • Both sides canonicalize with core realpath (realpathSync.native), the same helper as the record writer. So Windows case, 8.3 names, trailing dots and symlink aliases all match, and the JSON array round-trips paths containing : and ;.
  • Bad JSON throws and aborts render, preview and publish, so it fails closed.
  • Nit: a value with leading whitespace, or with relative entries, is dropped silently and reads as unset. Rejecting any non-empty value that yields no absolute path would be stricter.
  • add won't start a partial record in place of an expected-but-missing one (:130-131).
  • Follow-up, not blocking: the expectation is keyed by path and fixed when the process starts. If a folder is renamed and its record deleted, rendering or publishing it in the same run reads it as own until the Desktop side restores the record at run end. Copying has the same window. Carrying folder identity in the env value would close the rename case.
  • Locally 127 passed and 1 skipped (128) across privateProjectFile, receivedRender and add. Removing line 91 fails 4 tests. 6 probes passed: symlink in both directions, nested expected project, empty .hyperframes, bad JSON, leading whitespace and rename.
  • Commits are verified. No version bump or release.

Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅
Risk: low. Only projects a host names change behaviour, and leaving the variable unset keeps today's behaviour. The Windows lane was still pending at review time.

— Rames

…or all received

HYPERFRAMES_RECEIVED_STATE_FILE points at a JSON file a host app keeps,
listing project folders (by path, and optionally by device and inode) as
"expected" or "all". For an expected project, a missing received-files
record counts every file as received and is not started afresh; for an
all project, every file counts as received whatever the record lists. A
state file that is named but cannot be read counts every file as received.

A record lock dated in the future is taken over like a stale one.
@xuanruli
xuanruli force-pushed the fix/missing-provenance-record branch from 89cdc27 to 41e12de Compare November 17, 2026 06:11
@xuanruli xuanruli changed the title fix(cli): a received-files record a host says to expect reads as unknown when missing fix(cli): a host can name projects whose received files are expected or all received Nov 17, 2026
@xuanruli

Copy link
Copy Markdown
Collaborator Author

Independent serialized Devbox validation of the paired sources: OSS 41e12de8a610bc7558ae0a55329a7d44e6dbe671 + Desktop 2116ee0c0bcf1803e4411ca0d7b1cb19cbe61db0.

  • OSS privateProjectFile / receivedRender / add: 150 passed, 1 platform skip (151 total). Desktop focused suite: 85/85 passed. Node 22.23.0, existing Bun 1.3.14, isolated frozen-lock installs.
  • 2/2 cross-repository integration checks passed: actual Desktop beginReceived/runLaunch environment -> actual CLI cloud render --dry-run --json --include-outside-files child. A copied page during an active received-source run excludes benign ../outside.txt with reason received; deleting a known record after launch preparation also excludes it. End-of-run recording/restoration was asserted.

This verifies the source contract and local staging behavior, without upload or paid-model execution. It is not a signed-in Desktop walk, Windows validation, or published CLI artifact/pin verification. Those rollout requirements remain separately tracked.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE at e0f62317 (re-stamp; replaces my approval at 89cdc275, since the contract was rewritten)

  • The new host contract closes the follow-up from my last review.
    • A project the host marks "all" reads as received from itself, from its subfolders and from any folder that holds it.
    • An "expected" project whose record is missing reads as received.
    • Both still match after a rename or a same-disk move, through dev/ino.
  • Probed with the CLI check during a real host run:
    • A file copied in mid-run and the person's own index.html both read as received. Afterwards the copy is recorded and the rest reads as before.
    • A source that is renamed and stripped of its record reads as received, as does one moved deeper on the same disk.
  • Bad state fails closed. An empty, truncated, wrong-type or bad-entry state file reads every file as received, as do a directory, an unreadable file, a symlink to an unreadable file and a dangling symlink. With the variable unset or empty, behaviour is unchanged.
  • The stat/read race is gone. The state file is now read through one handle (openSync, then fstatSync and readFileSync on the same descriptor), and CodeQL alert 1371 shows fixed. The path is opened following symlinks, but only someone who can write the host's data folder can point it anywhere.
  • Locks: a future-dated lock is taken over (tryRecordLock).
  • Nits:
    • An "all" project that was renamed and still has its record reads as the person's own when rendered from a parent folder: the walk below reads the record and ignores the state. Treating hostState(dir) === "all" as unreadable in readRecord would close it.
    • Identity is dev:ino only. On ext4, a new folder that reused a gone project's inode read as received. That fails closed, but carrying birth time would avoid it.
  • Tests: locally 150 pass and 1 is skipped. Each of 6 mutations fails a test: unreadable state failing open, no expected-missing branch, no all record, no future-lock takeover, no identity match, and no below-overlap.
  • Commits are verified, and there's no version bump.

Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅
Risk: low. Only hosts that set the variable see a change, and every bad state reads as received.

— Rames

@xuanruli

Copy link
Copy Markdown
Collaborator Author

Windows CI on the e0f6231 merge preview failed a host's received state file > does not start a fresh record in place of an expected one: recordReceivedFiles returned ['index.html'] instead of refusing the partial record. Failing job.

5ec4dba makes walkStart use the shared core realpath helper, matching the writer's registryRoot. This avoids different native/non-native Windows path spellings in the host map lookup. Independently on Devbox: 150 passed, 1 platform skip across privateProjectFile, receivedRender and add; all normal commit hooks passed serially, and the commit is signed. Windows CI remains the platform verification; no Windows pass claimed from Linux tests.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE at 5ec4dba4 (re-stamp of e0f62317)

  • The delta is one verified commit, two lines in privateProjectFile.ts. walkStart now resolves with core's realpath (realpathSync.native) instead of Node's realpathSync, matching registryRoot and the record writer. On Windows, the JS realpathSync can return a different form (case, 8.3 short names) from the native call, so a host-state lookup could miss the path the record was written under.
  • The fallback to resolve(projectDir) on error is unchanged, and the rest of my review at e0f62317 stands.

Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅
Risk: low. Windows CI was rerunning at review time.

— Rames

@xuanruli
xuanruli enabled auto-merge November 17, 2026 07:30
@xuanruli

Copy link
Copy Markdown
Collaborator Author

Windows run 44038818187, checkout 335891a (5ec4dba merged with e21f56d), passed the original expected-record writer assertion. Its five remaining failures were receivedRender warning expectations: the test expected Windows short RUNNER~1 paths while warnings named the native runneradmin path.

Test-only commit 1a682d0 uses core's shared native realpath helper in the three expected-path sites. It retains the refusal, exact record path, warning count and outside-file assertions. Independent serial Devbox verification: 150 passed, 1 platform skip; all normal hooks passed. New Windows CI is required to establish the platform result; no rerun or assertion weakening used.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE at 1a682d08 (re-stamp of 5ec4dba4)

  • Test-only, one verified commit. In receivedRender.test.ts, three expected warning paths now use core's realpath (realpathSync.native) instead of realpathSync, matching what the code under test now prints. On Windows that's runneradmin rather than the RUNNER~1 short name.
  • Assertions are unchanged. The refusal (allowed false), the exact Could not read … line and the warn count are all kept.

Need ✅ · Size ✅ · Reuse ✅ · Simpler ✅
Risk: none (test only).

— Rames

@xuanruli
xuanruli added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 5ea8645 Nov 17, 2026
85 checks passed
@xuanruli
xuanruli deleted the fix/missing-provenance-record branch November 17, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants